#!/usr/bin/python

# Import module
#import random
#for cntr in range(0,10):
#    print random.randint(1,10)

# Another way to import module
#from random import randint
#for cntr in range(0,10):
#    print randint(1,10)

# define function
#def DoTwo(num1,num2):
#    """docstring for DoTwo"""
#    print('Adding the two numbers %d and %d = %d' % (num1, num2, num1+num2))
#    print('Multiplying the two numbers %d and %d = %d' % (num1, num2, num1*num2))
#    print('Substracting the two numbers %d and %d = %d' % (num1, num2, num1-num2))
#    print('\n')
#
#DoTwo(1,2)
#DoTwo(1,4)
#DoTwo(10,2)

# example to print shopping list

#def TopOrBottom(width):
#    """width is total width of returned line"""
#    return('%s%s%s' % ('+',('='*(width-2)),'+'))
#
#print(TopOrBottom(30))

def TopOrBottom(character,width):
    """width is total width of returned line, character is the word between '+'"""
    return '%s%s%s' % ('+',(character * (width-2)),'+') 

def Fmt(val1,leftbit,val2,rightbit):
    """prints two values padded with spaces"""
    """var1 is thing to print on left, val2 is thing to print on right"""
    """leftbit is width of left protin, rightbit is width of right portion"""
    part2 = '%.2f' % val2
    return '%s%s%s%s' % ('| ', val1.ljust(leftbit-2,' '), part2.rjust(rightbit-2,' '),' |')

# Define the prices of each item
#item1 = 3.00
#item2 = 15.00
items=[['Soda',1.45],['Candy',.75],['Bread',1.95],['Milk',2.59]]

# Now print everything
print(TopOrBottom('=',40))
#print(Fmt('Item 1',30,item1,10))
#print(Fmt('Item 3',30,item2,10))
total = 0
for cntr in range(0,4):
    print(Fmt(items[cntr][0],30,items[cntr][1],10))
    total += items[cntr][1]

print(TopOrBottom('-',40))
#print(Fmt('Total',30,item1+item2,10))
print(Fmt('Total',30,total,10))
print(Fmt('Tax:',30,total*.05,10))
print(TopOrBottom('=',40))
